package com.wangtao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wangtao.pojo.HouseResources;
import com.wangtao.service.HouseResourcesService;
import com.wangtao.vo.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class HouseResourcesServiceImpl extends BaseServiceImpl implements HouseResourcesService{
    @Override
    public int saveHouseResources(HouseResources houseResources) {
        if (StringUtils.isBlank(houseResources.getTitle())) {
            return -1;
        }
        return this.save(houseResources);
    }

    @Override
    public PageInfo<HouseResources> queryHouseResourcesList(int page, int pageSize, HouseResources queryCondition) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("updated");

        IPage pageList = this.queryPageList(queryWrapper, page, pageSize);

        return new PageInfo<HouseResources>((int) pageList.getTotal(), page, pageSize,pageList.getRecords());
    }
}

